package com.wx.app.mylib.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.mylib.R;


public class ToastHelper {

    public static void showToast(Context context, String msg) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }

    public static void showToast(Context context, int msg) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }

    //显示错误
    public static void showError(Context context, String msg) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_toast, null);
        TextView tipMsg = (TextView) view.findViewById(R.id.tip_toast_msg);
        tipMsg.setText(msg);
        Toast t = new Toast(context);
        t.setDuration(Toast.LENGTH_SHORT);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.setView(view);
        t.show();
    }

}
